package com.shycloud.mido.member.service.impl;

import java.util.Map;

import org.springframework.stereotype.Service;

import com.shycloud.mido.member.api.dto.MemberLoginInfo;
import com.shycloud.mido.member.handler.LoginHandler;
import com.shycloud.mido.member.service.MemberOauthService;

import lombok.AllArgsConstructor;

/**
 * 会员管理
 *
 * @author lxy
 * @date 2019-02-27 14:10:49
 */
@Service
@AllArgsConstructor
public class MemberOauthServiceImpl implements MemberOauthService {
	private final Map<String, LoginHandler> loginHandlerMap;

	/**
	 * 获取会员登录信息
	 *
	 * @param inStr inStr
	 * @return
	 */
	@Override
	public MemberLoginInfo getMemberDetails(String inStr) {
		String[] inStrs = inStr.split("@");
		String type = inStrs[0];
		String loginStr = inStrs[1];
		MemberLoginInfo handle = loginHandlerMap.get(type).handle(loginStr);
		return handle;
	}

	/**
	 * 获取会员登录信息
	 *
	 * @param inStr inStr
	 * @return
	 */
	@Override
	public MemberLoginInfo getMemberDetailsNew(String inStr) {
		return loginHandlerMap.get("PWD").handle(inStr);
	}
}
